﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DbDoc.BusinessObjects
{
    public class Setting
    {
        public int Id { get; set; }
        public string Key { get; set; }
        public string RawValue { get; set; }
        public string DataType { get; set; }
        public object Value
        {
            get { return ConvertValue(RawValue); }
        }

        private object ConvertValue(string value)
        {
            object convertedValue = null;
            switch (DataType)
            {
                case "bool": convertedValue = Boolean.Parse(value);
                    break;
                case "int": convertedValue = Boolean.Parse(value);
                    break;
                case "string": convertedValue = value;
                    break;
                default: convertedValue = value;
                    break;
            }
            return convertedValue;
        }
    }
}
